# -*- coding: utf-8 -*-
# created on 2016/04/07

from mathsolver.functions.base import BaseFunction
from mathsolver.functions.hanshu.dandiaoqujian import DaoShuDanDiao


# TODO: 合并单调区间，如果后面有需要再补充
class DaoShuDanDiaoHeBing(BaseFunction):
    """利用导数求函数的单调递增区间 - 含参数讨论结果合并递增、递减区间"""

    def solver(self, *args):
        dandiao_solver = DaoShuDanDiao().solver(*args)
        up, down = dandiao_solver.output[0].value

        # 不含参数
        if not isinstance(up, list):
            return dandiao_solver
        # 含参数，合并区间
        else:
            # 求函数导数
            self.steps.append(dandiao_solver.steps[0])
        self.label.add("利用导数求函数的单调区间")
        return self
